/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.metasketch.model.loader;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.metasketch.model.loader.links.ActionAndTaksLinkProvider;
import org.metasketch.model.loader.links.HumanActivityAndGroupLinkProvider;
import org.metasketch.model.loader.links.ParticipationMapLinkProvider;

/**
 * 
 * @author guilhermegrg
 */
public class LinkProviderManager {

	List<IGetLinkLogic> linkLogicProviders = new ArrayList<IGetLinkLogic>();

	public LinkProviderManager() {
		linkLogicProviders.add(new ParticipationMapLinkProvider());
		linkLogicProviders.add(new ActionAndTaksLinkProvider());
		linkLogicProviders.add(new HumanActivityAndGroupLinkProvider());
	}

	public Collection<GraphNode> getLinks(GraphNode node, String type,
			IGraphDatabase gdb) {
		String ntype = (String) node.getType();

		for (IGetLinkLogic linkLogicProvider : linkLogicProviders) {
			linkLogicProvider.setGdb(gdb);

			if (linkLogicProvider.canProcess(node, ntype, type)) {
				return linkLogicProvider.getLinks(node, type);
			}
		}

		return null;
	}
}
